import log from '@dfeidao/atom-nodejs/logger/log';
import msg from '@dfeidao/atom-nodejs/msg';
import { IncomingHttpHeaders } from 'http';
import { spaceid } from '../../atom/config';

interface Message {
	usercode: string;
	userpw: string;
	fid: string;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	log('Service begin path:login/zj-000001/s001,action_id:' + action_id);
	// const result = await msg.user_login(action_id, session_id, message.usercode, message.userpw);
	const result = await msg.call_service(action_id, session_id, 'loginservice.userlogin', { logintypenew: 'phone', spaceid, usercode: message.usercode, userpw: message.userpw }) as { sessionID: string };
	// const result = await login_with_phoneno(action_id, session_id, message.usercode, message.userpw, message.fid, 720);

	log('Service end path:login/zj-000001/s001,2,action_id:' + action_id);
	return {
		data: result, cookie: {
			sessionid: result.sessionID
		}
	};
}
